package com.cn.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cn.entity.User;
import com.cn.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {
    @Resource
    UserMapper userMapper;

    /**
     * 根据ID查询用户
     * @param userID 用户ID
     * @return user
     */
    public User getUserByID(String userID){
        return userMapper.selectById(userID);
    }

    /**
     * 根据用户名查询用户
     * @param userName 用户名
     * @param password 密码
     * @return user
     */
    public User getUserByName(String userName,String password){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("user_name",userName).eq("password",password);
        return userMapper.selectOne(wrapper);
    }
}
